<%@ page contentType="text/html; charset=UTF-8" %>
<%@page import="com.fick.hibernate.model.LinkClass,com.fick.hibernate.model.Admin" %>
<%@page import="com.fick.hibernate.dao.TxlDAO"%>
<%@page import="com.fick.hibernate.model.Txl,java.util.*"%>
<%@page import="java.text.SimpleDateFormat"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加通讯录</title>
<link href="images/jiahao.css" rel="stylesheet" type="text/css">
<script language="javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js" defer="defer"></script>
<script type="text/javascript">
<!--
			    function CheckForm() {
					if(document.form1.name.value=="")
					{
						alert("姓名不能为空");
						document.form1.name.focus();
						return false;
					}
					if(isNaN(document.form1.tel.value))
					{
						alert("内线只能为数字");
						document.form1.tel.focus();
						return false;
					}
					if(isNaN(document.form1.phone.value))
					{
						alert("手机只能为数字");
						document.form1.phone.focus();
						return false;
					}
					if(isNaN(document.form1.orderStr.value))
					{
						alert("序号只能为数字");
						document.form1.orderStr.value.focus();
						return false;
					}
					if(isNaN(document.form1.orderStr.value))
					{
						alert("序号只能为数字");
						document.form1.phone.focus();
						return false;
					}
				}
//-->
</script>
</head>

<body>
<table width="100%"  height="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="100%" align="center" valign="top" background="images/main_bj.gif" bgcolor="#FBFCFD"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="23" align="left" valign="middle" background="images/main_top.gif"><table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="20" height="23">&nbsp;</td>
            <td width="400" height="23" align="left" valign="middle" class="ts_lmdh2">添加通讯录</td>
          </tr>
        </table></td>
      </tr>
    </table>
      <table width="98%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="20"></td>
        </tr>
      </table>
	  
	  
	  <%
	  String id=request.getParameter("id");
	  Txl txl=null;
	  if(id!=null && id.trim().length()>0){
		  txl=new TxlDAO().findById(Integer.parseInt(id));
	  }
	  %>
<form name="form1" id="form1" action="<%=request.getContextPath()%>/admin/txlAction.do?method=add"  method="post" onSubmit="return CheckForm();" />
      <input type="hidden" name="id" value="<%=id==null?"":id %>"/>
      <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D7DFE1">
        <tr>
          <td width="50%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">姓名：</td>
          <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <input name="name"  size="30" value="<%=txl==null?"":txl.getName()%>"  type="text" class="ts_box3"/>
		  </td>
        </tr>
        <tr>
          <td width="50%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">生日：</td>
          <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
          <input name="birthday" id="birthday" class="Wdate" value="<%=txl==null?new SimpleDateFormat("yyyy-MM-dd").format(new Date()):new SimpleDateFormat("yyyy-MM-dd").format(txl.getAddTime()) %>" 
				type="text" size="22" value="" readonly
				onClick="WdatePicker({skin:'default',dateFmt:'yyyy-MM-dd'})" />
		  </td>
        </tr>
        <tr>
          <td width="50%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">内线：</td>
          <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <input name="tel"  size="30" value="<%=txl==null?"":txl.getTel() %>"  type="text" class="ts_box3"/>
		  </td>
        </tr>
       <tr>
          <td width="50%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">手机：</td>
          <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <input name="phone"  size="30" value="<%=txl==null?"":txl.getPhone() %>"  type="text" class="ts_box3"/>
		  </td>
        </tr>if ) {
        <%
		  			Admin admin=(Admin)request.getSession().getAttribute("admin");
			 		if(admin!=null &&  (admin.getRole().getId() == 3 || admin.getRole().getId() == 5  ))  //如果是管理员勤超级管理员可以查询所有
			 		{
         %>
        <tr>
          <td width="50%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">单位：</td>
          <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <%
			 		TxlDAO dao=new TxlDAO();
			 		List<String> unitList=dao.findBySql("SELECT distinct unit FROM admin where unit is not null"); 
			 	%>
			 		<select name="unit">
			 				<%
			 					for(int i = 0 ; i < unitList.size() ; i ++ ) {
			 					String unit = (String)unitList.get(i);
			 				%>
			 				<option value="<%=unit %>"><%=unit %></option>
			 				<%}%>
			 		</select>
		  </td>
        </tr>
        <%} %>
        <tr>
          <td width="50%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">备注：</td>
          <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <input name="bz"  size="30" value="<%=txl==null?"":txl.getBz()%>"  type="text" class="ts_box3"/>
		  </td>
        </tr>
          <tr>
          <td width="50%" height="25" align="right" valign="middle" bgcolor="#FFFFFF">序号：</td>
          <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <input name="orderStr"  size="30" value="<%=txl==null?"":txl.getOrderStr()%>"  type="text" class="ts_box3"/>
		  </td>
        </tr>
        <tr>
          <td height="30" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF">
		  <input type="submit" name="Submit" value="提交">
		  <input  type="button" value="返回" onClick="javascript:history.go(-1);">
		  </td>
        </tr>
      </table>
</form>	  
      <table width="98%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="45" align="center" valign="middle">&nbsp;</td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
